var gulp = require("gulp");
var del = require("del");
var browserify = require("browserify");
var source = require('vinyl-source-stream');
var tsify = require("tsify");

gulp.task("clean", function() {
  del(['dist']);
});

gulp.task("copy", function () {
  gulp.src(['src/app/*.html'])
      .pipe(gulp.dest("dist"));
  gulp.src(['src/assets/**/*'])
  .pipe(gulp.dest("dist/assets"));
});

gulp.task("build", ["copy"], function () {
  return browserify({
    basedir: '.',
    debug: true,
    entries: ['src/app/index.ts'],
    cache: {},
    packageCache: {}
  })
  .plugin(tsify)
  .bundle()
  .pipe(source('bundle.js'))
  .pipe(gulp.dest("dist"));
});
